package hu.village.controller;

import hu.village.pojo.Result;
import hu.village.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @GetMapping("village/upload")
    public Result upload(MultipartFile image) throws Exception{
        log.info("文件上传,文件名:{}", image.getOriginalFilename());
        //调用工具类上传文件
        String url = aliOSSUtils.upload(image);
        log.info("文件上传完成,url:{}", url);
        return Result.success( url );
    }
}
